package pages

import (
	"github.com/templui/templui/internal/ui/layouts"
	"github.com/templui/templui/internal/ui/modules"
	"github.com/templui/templui/internal/ui/showcase"
)

templ CopyButton() {
	@layouts.DocsLayout(
		"Copy Button",
		"Button component that copies content from target elements to clipboard.",
		[]modules.TableOfContentsItem{
			{
				ID:   "installation",
				Text: "Installation",
			},
			{
				ID:   "examples",
				Text: "Examples",
				Children: []modules.TableOfContentsItem{
					{
						ID:   "with_input",
						Text: "With Input",
					},
					{
						ID:   "with_code",
						Text: "With Code Block",
					},
				},
			},
			{
				ID:   "api",
				Text: "API Reference",
				Children: []modules.TableOfContentsItem{
					{
						ID:   "copybutton",
						Text: "CopyButton",
					},
				},
			},
		},
	) {
		@modules.PageWrapper(modules.PageWrapperProps{
			Name:        "Copy Button",
			Description: templ.Raw("Button component that copies content from target elements to clipboard."),
			Tailwind:    true,
			VanillaJS:   true,
			Breadcrumbs: modules.Breadcrumbs{
				Items: []modules.BreadcrumbItem{
					{
						Text: "Docs",
						Path: "/docs",
					},
					{
						Text: "Components",
						Path: "/docs/components",
					},
					{
						Text: "Copy Button",
					},
				},
			},
		}) {
			@modules.ExampleWrapper(modules.ExampleWrapperProps{
				ShowcaseFile:    showcase.CopyButtonDefault(),
				PreviewCodeFile: "copybutton_default.templ",
			})
			@modules.ContainerWrapper(modules.ContainerWrapperProps{
				Title: "Installation",
				ID:    "installation",
			}) {
				@modules.ComponentUsage(modules.ComponentUsageProps{
					ComponentName: "copybutton",
					JSFiles:       []string{"copybutton"},
				})
			}
			@modules.ContainerWrapper(modules.ContainerWrapperProps{
				Title: "Examples",
				ID:    "examples",
			}) {
				@modules.ExampleWrapper(modules.ExampleWrapperProps{
					SectionName:     "With Input",
					ShowcaseFile:    showcase.CopyButtonWithInput(),
					PreviewCodeFile: "copybutton_with_input.templ",
					ID:              "with_input",
				})
				@modules.ExampleWrapper(modules.ExampleWrapperProps{
					SectionName:     "With Code Block",
					ShowcaseFile:    showcase.CopyButtonWithCode(),
					PreviewCodeFile: "copybutton_with_code.templ",
					ID:              "with_code",
				})
			}
			@modules.ContainerWrapper(modules.ContainerWrapperProps{
				Title: "API Reference",
				ID:    "api",
			}) {
				@modules.APILegend()
				<div id="copybutton" class="mb-8">
					@modules.APITable(modules.APITableProps{
						Title:       "CopyButton",
						Description: "Button component that copies content from a target element to the clipboard.",
						Items: []modules.APITableItem{
							{
								Name:        "ID",
								Type:        "string",
								Default:     "",
								Description: "Unique identifier for the button element.",
								Required:    false,
							},
							{
								Name:        "Class",
								Type:        "string",
								Default:     "",
								Description: "Additional CSS classes to apply to the button.",
								Required:    false,
							},
							{
								Name:        "Attrs",
								Type:        "templ.Attributes",
								Default:     "",
								Description: "Additional HTML attributes to apply to the button element.",
								Required:    false,
							},
							{
								Name:        "TargetID",
								Type:        "string",
								Default:     "",
								Description: "ID of the element to copy content from. Automatically detects whether to use .value or .textContent.",
								Required:    true,
							},
						},
					})
				</div>
			}
		}
	}
}
